Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[venstarthermostat] Add more channels provided by the local API #11305

Conversation

raveydavies
Copy link
Contributor

<[Venstarthermostat] adding more functionality to match the local API>

<This Pull Request adds several enhancements to the Venstar Thermostat binding, as per enhancement issue 10823
#10823
Functionality added copies the functionality of the local API and is:
Fan Mode
Fan State
Schedule Mode
Schedule Part
Time Stamp for Run Time
Run Time in heat 1 mode
Run Time in heat 2 mode
Run Time in cool 1 mode
Run Time in cool 2 mode
Run Time in Aux 1 mode
Run Time in Aux 2 mode
Run Time in Free Cool mode

README is updated

<The updates have been tested in the Eclipse openHAB environment, and also on my Raspberry Pi with OpenHAB, using my thermostat device. I have a very simple heating system (central heating boiler), so could not test some channels with real equipment, but I have checked all channels update properly according to commands and the thermostat changes accordingly.

Signed-off-by: raveydavies <matthew.davies@skynet.be>
Signed-off-by: raveydavies <matthew.davies@skynet.be>
Signed-off-by: raveydavies <matthew.davies@skynet.be>
@digitaldan digitaldan changed the title Venstar binding more functions issue enhancement 10823 [venstar] more functions issue enhancement 10823 Sep 25, 2021
@digitaldan digitaldan changed the title [venstar] more functions issue enhancement 10823 [venstarthermostat] more functions issue enhancement 10823 Sep 25, 2021
Copy link
Contributor

@digitaldan digitaldan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thanks so much for these improvements!!!! I'm scratching my head wondering why we did not at least implement Fan mode and state, as those seem pretty useful, so i think your changes will be well received!

I added some feedback, mostly small stuff.

A note about the Runtime history. It looks like the API is sending the last 7 days of runtime history. The timestamp for the last day is always right now, which makes sense as its the current runtime of each type until right now from the last entry, once midnight happens, it becomes yesterday's values (so the timestamp remains the same and its now not the last entry in that array).

I could see just having this last entry (current runtime) could be useful for historic reasons and graphing (so putting values in grafana, rrd, etc...). In this case i would update the documentation to make this more clear, as the timestamp is confusing why it's alway right now and that also the runtime values start at midnight. It confused me, which is why i went looking a little deeper.

We could also add channels for each of the last 7 days, this would be great for users wanting to display this info on their OH UI. If we could start over, adding channel groups might have been nice, but you can't mix them in now. I would vote for this option if you want to keep the runtime functionality. In this case your channels might look like

<channel id="day0Heat1Runtime" typeId="heat1Runtime"/>
<channel id="day1Heat1Runtime" typeId="heat1Runtime"/>
<channel id="day2Heat1Runtime" typeId="heat1Runtime"/>
....
<channel id="day0Cool2Runtime" typeId="cool2Runtime"/>
<channel id="day1Cool2Runtime" typeId="cool2Runtime"/>
<channel id="day2Cool2Runtime" typeId="cool2Runtime"/>
...

and so on. WDYT?

| scheduleModeRaw | Number | Current Schedule mode Raw (Read Only)| 0(Disabled) 1(Enabled) |
| schedulePart | String | Current Schedule Part | |
| schedulePartRaw | Number | Schedule Part Raw (Read Only)|0(Morning) 1(Day) 2(Evening) 3 (Night) 255 (Inactive) |
| timestampRuntime | DateTime | Time Stamp of last RT update |Binding only looks at the last day runtime |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nit, i would replace all the RT abbreviations with Runtime to make this more clear to users

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK I will update it. By the way, how does this formatting of a table in Markdown (in Eclipse) work? Is there a tutorial on it somewhere? I'm not familiar at all with this stuff, so I was kind of trying to fit RT into a column, probably not necessary :-).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So put everything you want into the table, don't worry about formatting too much, then before you push your changes, use http://markdowntable.com/ to have it format your table with the correct spacing and such. This is how i do it, others may have a different approach. Eclipse has a very poor markdown editor and previewer.

<state readOnly="true" pattern="%d mins"/>
</channel-type>

<channel-type id="freecoolRuntime" advanced="false">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<channel-type id="freecoolRuntime" advanced="false">
<channel-type id="freeCoolRuntime" advanced="false">

Since "Free Cool" is two words, lets keep the camelCase pattern (and update the README as well).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK will update it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still needs to be fixed as well

return z;
}

private int getHeat1Runtime(VenstarRuntime runtime) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All these functions where you pass in the runtime are unnecessary, you can remove all of them and just call runtime.getHeat1() or other functions on the runtime object where you need it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was copying the approach that was in the code already. Yes, it seems a bit silly unless they are public functions.

@@ -338,23 +394,80 @@ private VenstarAwayMode getAwayMode() {
return infoData.getAway();
}

private void updateSettings(VenstarAwayMode away) {
private VenstarFanMode getFanMode() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So i don't know why we have these private functions that just duplicate the functions inside objects we hold here. If you want to just remove all of these, that would be great (not sure why i did not catch them when i got involved) For example anywhere that is calling getFanMode() can just use infoData.getFanMode(). If these were public i might seen a reason for them, but they are not and its just redundant code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree. I'll delete them, they are causing me a lot of unnecessary scrolling when I'm coding, it's driving me crazy.

* @author Matthew Davies - Class added to add more functionality to binding
*/
public class VenstarRuntime {
int ts;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

timestamps should be stored as a long vs an int

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. I will update it. Why is that? Coding convention because the number will eventually become very big?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, this will overrun a int in something like 2038 , which while a long while off, its still better to have consistency in coding conventions other wise we get a mess of ints and longs all over the place.


private ZonedDateTime getTimestampRuntime(VenstarRuntime runtime) {
ZonedDateTime z = ZonedDateTime.ofInstant(Instant.ofEpochSecond(runtime.getTimeStamp()),
ZoneId.systemDefault());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually it looks like this is reported in the user's timezone (or at least the time zone the device is set in) , so no need to convert to the system default time zone (or use GMT if you have to pass a timezone) . But this is actually more tricky as the runtime schedules are more complicated, i'll post that in another comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was struggling with this due to lack of familiarity with timestamps, epoch, etc (I'm really an amateur....). What should I put as the function argument to Instant.ofEpochSecond() instead of "ZoneId.systemDefault()"? It's very confusing. I also noticed the time displayed in the channel was 2 hours ahead of my home time zone.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this still needs to be resolved , or the time is always going to be off.

So this is kinda tricky, but i think you need to offset this back to UTC and then create a ZoneDate time. Dealing with time zones is always painful.

So maybe something like....

ZoneId  zoneId = ZoneId.systemDefault();
ZonedDateTime now = LocalDateTime.now().atZone(zoneId);
int diff = now.getOffset().getTotalSeconds();
ZonedDateTime z = ZonedDateTime.ofInstant(Instant.ofEpochSecond(runtime.getTimeStamp() -diff), zoneId);

@raveydavies
Copy link
Contributor Author

Thanks for the comments!! I will take a look at them in detail later today when I have some free time. About the runtimes....I was also wondering about including them all, it should be fairly easy to do. What's a channel group?

@digitaldan
Copy link
Contributor

Thanks for the comments!! I will take a look at them in detail later today when I have some free time. About the runtimes....I was also wondering about including them all, it should be fairly easy to do. What's a channel group?

See https://www.openhab.org/docs/developer/bindings/thing-xml.html#channel-groups , it allows you to define a group of channel types once and then refer to it many times (once for each day in this case). Unfortunately you either use ONLY channel groups OR individual channels, you can't mix them in a binding, so adding them would mean we break backwards compatibility for users. I think its ok, just means a little more copy and pasting in the thing xml file for each day, but in your code you can loop through the days and dynamically refer to the channels like (warning untested):

 private static final String CHANNEL_FMT = "day%d_%s";
          ....


            Collections.reverse(runtimes);
            for (int i = 0; i < 7; i++) {
                VenstarRuntime rt = null;
                if (i < runtimes.size()) {
                    rt = runtimes.get(i);
                }
                updateIfChanged(String.format(CHANNEL_FMT, i, CHANNEL_TIMESTAMP_RUNTIME),
                        rt == null ? UnDefType.UNDEF : new DateTimeType(getTimestampRuntime(lastRuntime)));
                updateIfChanged(String.format(CHANNEL_FMT, i, CHANNEL_HEAT1_RUNTIME),
                        rt == null ? UnDefType.UNDEF : new DecimalType(rt.getHeat1()));
                updateIfChanged(String.format(CHANNEL_FMT, i, CHANNEL_HEAT2_RUNTIME),
                        rt == null ? UnDefType.UNDEF : new DecimalType(rt.getHeat2()));
                updateIfChanged(String.format(CHANNEL_FMT, i, CHANNEL_COOL1_RUNTIME),
                        rt == null ? UnDefType.UNDEF : new DecimalType(rt.getCool1()));
                updateIfChanged(String.format(CHANNEL_FMT, i, CHANNEL_COOL2_RUNTIME),
                        rt == null ? UnDefType.UNDEF : new DecimalType(rt.getCool2()));
                updateIfChanged(String.format(CHANNEL_FMT, i, CHANNEL_AUX1_RUNTIME),
                        rt == null ? UnDefType.UNDEF : new DecimalType(rt.getAux1()));
                updateIfChanged(String.format(CHANNEL_FMT, i, CHANNEL_AUX2_RUNTIME),
                        rt == null ? UnDefType.UNDEF : new DecimalType(rt.getAux2()));
                updateIfChanged(String.format(CHANNEL_FMT, i, CHANNEL_FC_RUNTIME),
                        rt == null ? UnDefType.UNDEF : new DecimalType(rt.getFC()));
            }

I'm assuming there may not always be 7 days (like when its reset or something)
The channel constants would need to be changed to start with a capital letter of course to keep the camerlCase pattern.

@raveydavies
Copy link
Contributor Author

Hi, thanks so much for these improvements!!!! I'm scratching my head wondering why we did not at least implement Fan mode and state, as those seem pretty useful, so i think your changes will be well received!

I added some feedback, mostly small stuff.

A note about the Runtime history. It looks like the API is sending the last 7 days of runtime history. The timestamp for the last day is always right now, which makes sense as its the current runtime of each type until right now from the last entry, once midnight happens, it becomes yesterday's values (so the timestamp remains the same and its now not the last entry in that array).

I could see just having this last entry (current runtime) could be useful for historic reasons and graphing (so putting values in grafana, rrd, etc...). In this case i would update the documentation to make this more clear, as the timestamp is confusing why it's alway right now and that also the runtime values start at midnight. It confused me, which is why i went looking a little deeper.

We could also add channels for each of the last 7 days, this would be great for users wanting to display this info on their OH UI. If we could start over, adding channel groups might have been nice, but you can't mix them in now. I would vote for this option if you want to keep the runtime functionality. In this case your channels might look like

<channel id="day0Heat1Runtime" typeId="heat1Runtime"/>
<channel id="day1Heat1Runtime" typeId="heat1Runtime"/>
<channel id="day2Heat1Runtime" typeId="heat1Runtime"/>
....
<channel id="day0Cool2Runtime" typeId="cool2Runtime"/>
<channel id="day1Cool2Runtime" typeId="cool2Runtime"/>
<channel id="day2Cool2Runtime" typeId="cool2Runtime"/>
...

and so on. WDYT?

Yes I agree with this as well. Do you think the timestamps are needed? Or would it be better to just have channels labeled "Today Heat1 Runtime", "Yesterday Heat1 Runtime", " 2 days ago Heat1 Runtime"........?

@digitaldan
Copy link
Contributor

Yes I agree with this as well. Do you think the timestamps are needed?

It couldn't hurt, I would just mark the channel as "advanced" so it not shown by default in the UI

Or would it be better to just have channels labeled "Today Heat1 Runtime", "Yesterday Heat1 Runtime", " 2 days ago Heat1 Runtime"........?

Yes, exactly ! The labels and Readme can more clearly state "Today, Yesterday, 2 Days ago, 3 Days ago,......" and so on.

@raveydavies
Copy link
Contributor Author

@digitaldan I'm working on the above changes. It will take me a couple of days. I'll commit the code when it's done and tested.

@digitaldan digitaldan added the work in progress A PR that is not yet ready to be merged label Sep 30, 2021
Signed-off-by: raveydavies <matthew.davies@skynet.be>
@raveydavies
Copy link
Contributor Author

@digitaldan did my last commit come through OK? Something strange happened at my end, but to me it looks OK.


runtimeData = Objects.requireNonNull(gson.fromJson(response, VenstarRuntimeData.class));
List<VenstarRuntime> runtimes = runtimeData.getRuntimes();
String[] timestamps = { CHANNEL_TIMESTAMP_RUNTIME_DAY0, CHANNEL_TIMESTAMP_RUNTIME_DAY1,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you don't want to dynamically reference a single set of base channels vars like CHANNEL_TIMESTAMP_RUNTIME_DAY + i thats fine, but theres a lot more code being copied and pasted around which is not my fav. If you do want to keep all these extra channels variables, arrays like these should be moved to VenstarThermostatBindingConstants or to the top of this file and be declared static final with the variable names in all caps (like other static final vars) so they are only created once.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree it's getting messy. I didn't like it when I programmed it, but I'm not sure how to resolve it (your CHANNEL_NAME+i won't work, will it?). I was actually wondering if it would be cleaner just to provide the runtime string, and let users do whatever they want with it (with some explanation of the String content in the documentation). I suspect anyone trying to do anything with this data will be quite "hardcore" anyway.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why would that not work? If you define a Variable like

public static final String CHANNEL_TIMESTAMP_RUNTIME_DAY = "timestampDay";

then in a loop set then channel String value to

updateIfChanged(CHANNEL_TIMESTAMP_RUNTIME_DAY + i, new DateTimeType(getTimestampRuntime(rt)));

Then the channel name is going to be

timestampDay0
timestampDay1
timestampDay2
....

adding a String to a int results in concatenating the two together as essentially 2 strings. And you save yourself a whole lot of code to maintain. If we were doing this 1000's of time per second, then i agree having static tables would be more efficient , but if performance is not a issue, i would error on the side of maintainability.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!! Sounds good....I will update it. I guess I had somehow forgotten the variable values are strings.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about just providing the runtime string as it comes directly from the thermostat, as a simplification? I suppose as I've already done a lot of code around this, it's not worth reversing :-)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about just providing the runtime string as it comes directly from the thermostat,

Not sure what you mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was just thinking it would be simpler to provide the raw json response from '.../query/runtimes' and let people do whatever they want with it with a JSON / Regex transformation operation. That would avoid all the extra channels and code we currently have (I don't like the fact the binding currently has 56 channels and 2 classes for this - it's messy :-O). A json probably wouldn't be too difficult to handle for people that are likely to use the data (it's not really core thermostat functionality). The thermostat also gives alarms in a similar format, which would again require multiple channels and classes unless a JSON response is used.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, returning raw JSON is not a great choice here. I am fine with the extra channels and classes, you can mark them as advanced, and they won't show up by default in the UI, so it should not intimidate users. Returning in JSON will ensure very few people would ever use this. Again, if you dynamically create the channel names as we discussed a few times, then its just the thing XML which is long, but there are definitely bindings with more in them, so not out of the ordinary .

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@digitaldan OK. I did the updates you suggested anyway. They are in my latest commit/push in this pull request.

String[] aux2Runtimes = { CHANNEL_AUX2_RUNTIME_DAY0, CHANNEL_AUX2_RUNTIME_DAY1, CHANNEL_AUX2_RUNTIME_DAY2,
CHANNEL_AUX2_RUNTIME_DAY3, CHANNEL_AUX2_RUNTIME_DAY4, CHANNEL_AUX2_RUNTIME_DAY5,
CHANNEL_AUX2_RUNTIME_DAY6 };
String[] fCRuntimes = { CHANNEL_FC_RUNTIME_DAY0, CHANNEL_FC_RUNTIME_DAY1, CHANNEL_FC_RUNTIME_DAY2,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

Suggested change
String[] fCRuntimes = { CHANNEL_FC_RUNTIME_DAY0, CHANNEL_FC_RUNTIME_DAY1, CHANNEL_FC_RUNTIME_DAY2,
String[] fcRuntimes = { CHANNEL_FC_RUNTIME_DAY0, CHANNEL_FC_RUNTIME_DAY1, CHANNEL_FC_RUNTIME_DAY2,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it should be fC like the individual variable names. Why not?

Copy link
Contributor

@digitaldan digitaldan Oct 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

b/c you clearly use fc as a single word here CHANNEL_FC_RUNTIME_DAY0 not CHANNEL_F_C_RUNTIME_DAY0 , and i agree FC is better then F_C


private ZonedDateTime getTimestampRuntime(VenstarRuntime runtime) {
ZonedDateTime z = ZonedDateTime.ofInstant(Instant.ofEpochSecond(runtime.getTimeStamp()),
ZoneId.systemDefault());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this still needs to be resolved , or the time is always going to be off.

So this is kinda tricky, but i think you need to offset this back to UTC and then create a ZoneDate time. Dealing with time zones is always painful.

So maybe something like....

ZoneId  zoneId = ZoneId.systemDefault();
ZonedDateTime now = LocalDateTime.now().atZone(zoneId);
int diff = now.getOffset().getTotalSeconds();
ZonedDateTime z = ZonedDateTime.ofInstant(Instant.ofEpochSecond(runtime.getTimeStamp() -diff), zoneId);

Signed-off-by: raveydavies <matthew.davies@skynet.be>
@raveydavies
Copy link
Contributor Author

@digitaldan I've made updates according to the comments, I think I addressed everything. Thanks for the coaching.....it's very useful for a self-taught programmer who never needed to code to any kind of standard or go through any peer review before :-)

@digitaldan
Copy link
Contributor

I've made updates according to the comments, I think I addressed everything. Thanks for the coaching.....it's very useful for a self-taught programmer who never needed to code to any kind of standard or go through any peer review before :-)

No worries, these are nice enhancements, and i'm happy to help.

Copy link
Contributor

@digitaldan digitaldan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi , sorry for the delay, didn't catch you had made updates, see my review notes for latest round of feedback, thanks !

ZonedDateTime now = LocalDateTime.now().atZone(zoneId);
int diff = now.getOffset().getTotalSeconds();
ZonedDateTime z = ZonedDateTime.ofInstant(Instant.ofEpochSecond(runtime.getTimeStamp() - diff), zoneId);
// ZonedDateTime z = ZonedDateTime.ofInstant(Instant.ofEpochSecond(runtime.getTimeStamp()),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove commented out code

@@ -93,10 +108,19 @@

private static final int TIMEOUT_SECONDS = 30;
private static final int UPDATE_AFTER_COMMAND_SECONDS = 2;
private static final String CHANNEL_TIMESTAMP_RUNTIME_DAY = "timestampDay";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put these in VenstarThermostatBindingConstants

public static final String CHANNEL_SCHEDULE_MODE_RAW = "scheduleModeRaw";
public static final String CHANNEL_SCHEDULE_PART = "schedulePart";
public static final String CHANNEL_SCHEDULE_PART_RAW = "schedulePartRaw";
public static final String CHANNEL_TIMESTAMP_RUNTIME_DAY0 = "timestampDay0";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove all of the CHANNEL_xxx_xxx_Dayx strings as they are no longer referenced anywhere.

| scheduleMode | String | Current Schedule Mode | |
| scheduleModeRaw | Number | Current Schedule mode Raw (Read Only) | 0(Disabled) 1(Enabled) |
| schedulePart | String | Current Schedule Part | |
| schedulePartRaw | Number | Schedule Part Raw (Read Only) |0(Morning) 1(Day) 2(Evening) 3 (Night) 255 (Inactive) |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nit, but will come up with other reviewers as well, run the table through a formatter or manually fix the spacing issue on this line.

<state readOnly="true" pattern="%d mins"/>
</channel-type>

<channel-type id="freecoolRuntime" advanced="false">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still needs to be fixed as well

Signed-off-by: raveydavies <matthew.davies@skynet.be>
@raveydavies
Copy link
Contributor Author

@digitaldan Hi - I updated as per your review. I think I have finally got the freeCool camelCase right and the same everywhere!! I also made all the Runtime channels advanced. Everything seems to be working correctly with my thermostat. Let me know if anything else is needed. Thanks again.

@raveydavies
Copy link
Contributor Author

@digitaldan just wondering if it's worth including the "alerts" provided by the API while we're at it. I think that's the only functionality which is not included now, apart from some data only applicable on commercial devices. WDYT?

@digitaldan
Copy link
Contributor

HI looks good! There are some checkstyle warnings you can find in target/code-analysis/report.html that need to be fixed, but after that i'm good.

@digitaldan just wondering if it's worth including the "alerts" provided by the API while we're at it. I think that's the only functionality which is not included now, apart from some data only applicable on commercial devices. WDYT?

That sounds great, but let's open another PR for that and get this one merged in the meantime.

Signed-off-by: raveydavies <matthew.davies@skynet.be>
@raveydavies
Copy link
Contributor Author

@digitaldan Thanks!! I can't see what the problem is with the checkstyle warnings about first author, in the Runtime and RuntimeData classes. What am I missing? I've corrected the other ones and pushed again.

@digitaldan
Copy link
Contributor

Its very small formatting issues, should only take a min to fix. Its possible (likely) those existed before, but we were not using or checking checkstyle then. In any case this should be cleaned up for consistency as we do enforce this now.

image

@raveydavies
Copy link
Contributor Author

I've fixed those. See my last commit. I previously also saw a warning about first author contribution but that's gone now. All should be fine with my last commit.

@digitaldan digitaldan added the rebuild Triggers Jenkins PR build label Oct 15, 2021
Signed-off-by: raveydavies <matthew.davies@skynet.be>
@raveydavies
Copy link
Contributor Author

@lolodomo I think I addressed all your comments this time. Not sure what to do about the @NonNullByDefault for the serializer classes - the JsonDeserializer interface would need to be modified. Thanks for the detailed feedback, and for catching some of my really silly mistakes.

@lolodomo
Copy link
Contributor

lolodomo commented Nov 21, 2021

@raveydavies : this is almost ok now. Please fix the two minor comments you did not handle properly (comments marked as not yet resolved) and consider the last one I just added about handling fromInt exception.
Regarding the kind oif channels to be added (fanState and scheduleMode), I would like to have @digitaldan opinion.

@raveydavies
Copy link
Contributor Author

Oops. I missed those other calls to the fromInt method. I will correct them. What do you mean about the types of channels? What are you referring to?

@lolodomo
Copy link
Contributor

What do you mean about the types of channels? What are you referring to?

I mean the kind of item attached to the channel. It can be a switch, a string, a number, ... You chose "String" while I think "Switch" would have been more appropriate. You just made a choice, this is not a bug.

@lolodomo lolodomo added enhancement An enhancement or new feature for an existing add-on and removed awaiting feedback Awaiting feedback from the pull request author labels Nov 22, 2021
Signed-off-by: raveydavies <matthew.davies@skynet.be>
@raveydavies
Copy link
Contributor Author

@lolodomo updated again as per your review. Change the FanState Type to a switch, and added Exception Handling in the Serializer classes. Hope it's OK now....it works with my thermostat.

Copy link
Contributor

@lolodomo lolodomo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lolodomo lolodomo merged commit 6c6c93e into openhab:main Dec 4, 2021
@lolodomo
Copy link
Contributor

lolodomo commented Dec 4, 2021

Thank you @raveydavies

@lolodomo lolodomo added this to the 3.2 milestone Dec 4, 2021
@kaikreuzer
Copy link
Member

@lolodomo One quick wish when squashing+merging PRs: Please clean up the commit message when squashing to only keep the relevant information and a single sign-off line - otherwise they look like this. Thank you!

@lolodomo
Copy link
Contributor

lolodomo commented Dec 4, 2021

@kaikreuzer : that is noted for next times.

@kaikreuzer
Copy link
Member

@lolodomo Many thanks. I know that this isn't documented anywhere and I should have mentioned this upfront, sorry for missing out on it.

@raveydavies
Copy link
Contributor Author

Thanks @lolodomo @digitaldan for all for the help and feedback. It was tough for me to get that right, but we got there 😅. I learned a lot again.

@raveydavies raveydavies deleted the venstar-binding-more-functions-issue-enhancement-10823 branch December 4, 2021 21:38
@raveydavies
Copy link
Contributor Author

@lolodomo I noticed a documentation error related to this PR. I forgot to change the item type for fan state to a Switch in the doc after changing it in the code. Is there a way to quickly update it or do I need to create another issue / PR?

@lolodomo
Copy link
Contributor

lolodomo commented Dec 6, 2021

Yes please create a new PR.

@wborn wborn changed the title [venstarthermostat] more functions issue enhancement 10823 [venstarthermostat] Add more channels provided by the local API Dec 18, 2021
NickWaterton pushed a commit to NickWaterton/openhab-addons that referenced this pull request Dec 30, 2021
…1305)

* Adding several functions to binding to mimic local API

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* Adding functionality according to API

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* Updating Read me with new capability

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* Additional commit with requested changes to pull request

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* Updates to address all comments on previous commit.

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* Updates as requested in review.

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* Corrections for check style warnings

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* Updates to address feedback from lolodomo.

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* Changes to address feedback from lolodomo's review

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* FanState changed to Switch, Exception handling added as per review.

Signed-off-by: raveydavies <matthew.davies@skynet.be>
Signed-off-by: Nick Waterton <n.waterton@outlook.com>
mischmidt83 pushed a commit to mischmidt83/openhab-addons that referenced this pull request Jan 9, 2022
…1305)

* Adding several functions to binding to mimic local API

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* Adding functionality according to API

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* Updating Read me with new capability

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* Additional commit with requested changes to pull request

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* Updates to address all comments on previous commit.

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* Updates as requested in review.

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* Corrections for check style warnings

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* Updates to address feedback from lolodomo.

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* Changes to address feedback from lolodomo's review

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* FanState changed to Switch, Exception handling added as per review.

Signed-off-by: raveydavies <matthew.davies@skynet.be>
Signed-off-by: Michael Schmidt <mi.schmidt.83@gmail.com>
nemerdaud pushed a commit to nemerdaud/openhab-addons that referenced this pull request Jan 28, 2022
…1305)

* Adding several functions to binding to mimic local API

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* Adding functionality according to API

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* Updating Read me with new capability

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* Additional commit with requested changes to pull request

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* Updates to address all comments on previous commit.

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* Updates as requested in review.

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* Corrections for check style warnings

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* Updates to address feedback from lolodomo.

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* Changes to address feedback from lolodomo's review

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* FanState changed to Switch, Exception handling added as per review.

Signed-off-by: raveydavies <matthew.davies@skynet.be>
marcfischerboschio pushed a commit to bosch-io/openhab-addons that referenced this pull request May 5, 2022
…1305)

* Adding several functions to binding to mimic local API

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* Adding functionality according to API

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* Updating Read me with new capability

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* Additional commit with requested changes to pull request

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* Updates to address all comments on previous commit.

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* Updates as requested in review.

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* Corrections for check style warnings

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* Updates to address feedback from lolodomo.

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* Changes to address feedback from lolodomo's review

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* FanState changed to Switch, Exception handling added as per review.

Signed-off-by: raveydavies <matthew.davies@skynet.be>
andan67 pushed a commit to andan67/openhab-addons that referenced this pull request Nov 6, 2022
…1305)

* Adding several functions to binding to mimic local API

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* Adding functionality according to API

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* Updating Read me with new capability

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* Additional commit with requested changes to pull request

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* Updates to address all comments on previous commit.

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* Updates as requested in review.

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* Corrections for check style warnings

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* Updates to address feedback from lolodomo.

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* Changes to address feedback from lolodomo's review

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* FanState changed to Switch, Exception handling added as per review.

Signed-off-by: raveydavies <matthew.davies@skynet.be>
andrasU pushed a commit to andrasU/openhab-addons that referenced this pull request Nov 12, 2022
…1305)

* Adding several functions to binding to mimic local API

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* Adding functionality according to API

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* Updating Read me with new capability

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* Additional commit with requested changes to pull request

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* Updates to address all comments on previous commit.

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* Updates as requested in review.

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* Corrections for check style warnings

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* Updates to address feedback from lolodomo.

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* Changes to address feedback from lolodomo's review

Signed-off-by: raveydavies <matthew.davies@skynet.be>

* FanState changed to Switch, Exception handling added as per review.

Signed-off-by: raveydavies <matthew.davies@skynet.be>
Signed-off-by: Andras Uhrin <andras.uhrin@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature for an existing add-on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants